/*-------------------------------------------------------------------------------
* file:     app_lowpower.h
* brief:    application
* copyright Copyright (C) 2020-2022 @ NanoIC
* Date:     2022-08-15
* Version:  V1.00
* Author:   JMH
*-------------------------------------------------------------------------------*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_LOWPOWER_H__
#define __APP_LOWPOWER_H__

/* Includes ------------------------------------------------------------------*/
#include "common.h"
#include "pin.h"
#include "pm.h"
#include <drv/iwdt.h>
/*----------------------------------------------------------------------------*/
#include "app_timer.h"
#include "one_wire_bus_app.h"
#include "sys_console.h"
#include "app_cfg.h"
#include "app_init.h"
#include "app_uart.h"
#include "app_key.h"
#include "app_touchpad.h"
#include "app_gsensor.h"
#include "one_wire_bus_phy.h"
#include "app_sleeptimer.h"

/* Private macro-----------------------------------------------------------*/
#define     KEYBOARD_ENTRY_LOWPOWER_TIMER       50
#define     CLOSE_SYS_WDT_FLAG                  0x74AEF926

/*----------------------------------------------------------------------------*/
extern volatile uint16_t delay_key_done_disable_tp_tick; //按键抬起禁用触摸板0.4s计时
extern volatile uint16_t delay_key_done_2_s_disable_tp_tick;
extern volatile bool global_weakup_flag; //唤醒标志
extern uint8_t one_wire_bus_app_sleep_or_wakeup_flag;
/**
 * @brief ：低功耗初始化函数
 * 
 * @param
 * @return
 */
void app_lowpower_init(void);

/**
 * @brief ：定时器调用的低功耗相关函数
 * 
 * @param
 * @return
 */
void app_lowpower_timer_tick_0_1ms_callback(void);

/**
 * @brief ：设置键盘马上休眠
 */
void app_lowpower_sleep_set(void);

/**
 * @brief ：设置键盘退出休眠
 * 
 */
void app_lowpower_sleep_clear(void);

/**
 * @brief 控制发送唤醒包
 * 
 */
void app_send_wake_info_delay(void);

/**
 * @brief : 低功耗处理进程
 * 
 * @param 
 * @return 
 */
void  app_lowpower_process(void);

/**
 * @brief 设置tp禁用时间
 * 
 */
void app_lowpower_disable_tp_set(void);

/**
 * @brief 设置tp禁用时间
 * 
 */
void app_lowpower_key_up__disable_tp(void);

/**
 * @brief 设置禁用标志
 */
void app_lowpower_set_in_sleep_flag(void);

void app_sleep_timer_clear(void);
#endif
